import yaml
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
import pytest
from guoqingzuoye2.Page import Page
from guoqingzuoye1.Page1 import Page1
from guoqingzuoye1.Page2 import Page2

def read():
    with open('jiuxian.yaml','r',encoding='utf-8')as f:
        return yaml.safe_load(f)
a=read()
@pytest.fixture(scope='function')
def driver()->None:
    driver=webdriver.Chrome()
    driver.maximize_window()
    driver.implicitly_wait(10)
    yield driver
    driver.quit()

@pytest.mark.parametrize('jx',a)
def test_jiuxian_login(driver,jx):
    po1=Page(driver)
    po1.open_url('https://www.jiuxian.com/')
    sleep(2)
    po1.get_logg()
    sleep(2)
    po1.username(username=jx.get('username'))
    sleep(2)
    po1.password(password=jx.get('password'))
    sleep(7)
    po1.login_button()
    sleep(2)
    po1.quedd()
    sleep(2)

# def test_jiuxian_02(driver):
#     test_jiuxian_login(driver)
#     po2=Page1(driver)
#     po2.jiuxian_02()
#
# def test_jiuxian_03(driver):
#     test_jiuxian_login(driver)
#     po3=Page2(driver)
#     po3.jiuxian_03()